<template>
  <div class="menu">
  <el-table :data="userList.slice((currentPage-1)*pageSize,currentPage*pageSize)">
    <el-table-column prop="date" label="Date" width="140"/>
    <el-table-column prop="name" label="Name" width="120"/>
    <el-table-column prop="address" label="Address"/>
  </el-table>
  <el-pagination
      background
      layout=" prev, pager, next,sizes, jumper ,->,total,slot"
      :total="userList.length"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-size="pageSize"
      :page-sizes="[2,3,4]"
      style="text-align: center"
      @size-change="handleSizeChange">
  </el-pagination>
  </div>
</template>

<script>
export default {
  name: "Menu2",
  data() {
    return {
      currentPage: 1,
      pageSize: 4,
      userList: [{
        date: '2016-05-02',
        name: 'Tom1',
        address: 'No. 189, Grove St, Los Angeles',
      }, {
        date: '2016-05-02',
        name: 'Tom2',
        address: 'No. 189, Grove St, Los Angeles',
      }, {
        date: '2016-05-02',
        name: 'Tom3',
        address: 'No. 189, Grove St, Los Angeles',
      }, {
        date: '2016-05-02',
        name: 'Tom4',
        address: 'No. 189, Grove St, Los Angeles',
      }, {
        date: '2016-05-02',
        name: 'Tom5',
        address: 'No. 189, Grove St, Los Angeles',
      }, {
        date: '2016-05-02',
        name: 'Tom6',
        address: 'No. 189, Grove St, Los Angeles',
      }]
    }
  },
  methods:{
    handleCurrentChange(currentPage) {
      this.currentPage = currentPage; //每次点击分页按钮，当前页发生变化
      console.log(this.currentPage);
    },
    handleSizeChange(number) {
      this.pageSize = number;
      console.log("页面大小:"+this.pageSize);
    }
  }
}
</script>

<style scoped>

</style>